<template>
  <div class="pc-home" v-if="!isphone"></div>
  <div v-else class="phone-home">
    <van-nav-bar
      title="标题"
      left-text="返回"
      left-arrow
      @click-left="$router.go(-1)"
    />
    <div class="headinfo">
      <div class="headpic"><img :src="blogcontent.headpic" alt="" /></div>
      <div class="username">
        <span>{{ blogcontent.author }}</span>
        <i>发表于:2022-7-5</i>
      </div>
    </div>
    <div class="content">
      <img :src="blogcontent.img" alt="" />
      <p>
        {{ blogcontent.content }}
      </p>
    </div>
    <cmt></cmt>
  </div>
</template>
<script>
import cmt from '@/components/comment';
import { mapState } from 'vuex';
import { getblogcontent } from '@/api';
export default {
  data() {
    return {
      blogcontent: {},
    };
  },
  computed: {
    // 取出media中的isphone 其他页面按此方法取值
    // isphone为true时，手机端模板，否则网页端模板
    ...mapState('media', ['isphone']),
  },
  components: {
    cmt,
  },
  created() {
    getblogcontent({ id: this.$route.params.id }).then((res) => {
      this.blogcontent = res.data.data[0];
    });
  },
};
</script>
<style lang="scss" scoped>
.pc-home {
}
.phone-home {
  .headinfo {
    margin-top: 15px;
    width: 100%;
    height: 50px;
    padding-left: 10px;
    display: flex;
    .headpic {
      width: 50px;
      height: 50px;
      background-color: red;
      border-radius: 50%;
      margin-right: 10px;
      overflow: hidden;
      img {
        width: 50px;
        height: 50px;
      }
    }
    .username {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      span {
        font-size: 20px;
        color: black;
        font-weight: bold;
      }
      i {
        color: gray;
      }
    }
  }
  .content {
    padding: 0 10px;
    margin-top: 20px;
    img {
      width: 100%;
    }
    p {
      margin-top: 20px;
      text-indent: 40px;
      font-size: 20px;
      color: black;
      font-weight: bold;
      text-align: left;
    }
  }
}
</style>
